//连接数据库
var mysql = require('mysql');
var connection = mysql.createConnection({
    host: 'bdm253137448.my3w.com', //数据库地址
    user: 'bdm253137448',   //用户名称
    password: 'muchengfeng123', //数据库管理密码
    database:'bdm253137448_db', //数据库名称
    insecureAuth: true
});

connection.connect(function(err) {
    if (err) {
        console.error('error connecting: ' + err.stack);
        return;
    }

    console.log('connected as id ' + connection.threadId);
});


/*
 max()函数是求最大值的函数
 * */
var  userGetSql = ' select max(id) 最大值  FROM userinfo where id > 3 ';
//查 query
connection.query(userGetSql,function (err, result) {
    if(err){
        console.log('[SELECT ERROR] - ',err.message);
        return;
    }

    console.log('---------------SELECT----------------');
    console.log(result);
    console.log('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$');
});
//关闭连接
connection.end();
